package com.mxf.code.Controller;

import com.mxf.code.entity.Person;
import com.mxf.code.enums.Gender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author mxf
 * @version 1.0
 * @description: 枚举Controller
 * @date 2023/5/25
 */
@RestController
@RequestMapping("enum/test")
@Slf4j
public class EnumController {

    @GetMapping("getTest01")
    @ResponseBody
    public Gender getTest01(@ModelAttribute("gender") Gender gender) {
        return gender;
    }

    @GetMapping("getTest02")
    public Person getTest02(Person person) {
        return person;
    }

    @PostMapping("postTest01")
    @ResponseBody
    public Gender postTest01(@ModelAttribute("gender") Gender gender) {
        return gender;
    }

    @PostMapping("postTest02")
    public Person postTest02(@RequestBody Person person) {
        return person;
    }

    @PutMapping("putTest01")
    public Gender putTest01(@ModelAttribute("gender") Gender gender) {
        return gender;
    }

    @PutMapping("putTest02")
    public Gender putTest02(@RequestBody Person person) {
        return person.getGender();
    }

    @PutMapping("putTest03")
    public Person putTest03(@RequestBody Person person) {
        return person;
    }
}
